package neusoft.yuejian_11.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import neusoft.yuejian_11.adapter.TrainCollectAdapter;
import neusoft.yuejian_11.base.BaseFragment;
import neusoft.yuejian_11.bean.TrainCollectBean;
import neusoft.yuejian_11.listener.RetrofitListener;
import neusoft.yuejian_11.model.AttentionModel;
import neusoft.yuejian_11.R;

/**
 * A simple {@link Fragment} subclass.
 */
//我的关注（培训）
public class MyCollectTrainFragment extends BaseFragment  implements RetrofitListener {
    private RecyclerView recyclerView;
    private TrainCollectAdapter adapter;


    public MyCollectTrainFragment() {
        // Required empty public constructor
    }
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        recyclerView = view.findViewById(R.id.recyclerView);
        initData();


    }

    private void initData() {
        AttentionModel attentionModel=new AttentionModel();
        attentionModel.getTrainCollectlist(getU_id(),"0",this);
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_my_collect_train, container, false);
    }

    @Override
    public void onSuccess(Object o, int flag) {
        List<TrainCollectBean> m=(List<TrainCollectBean>)o;
        adapter=new TrainCollectAdapter(getActivity(),m);
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(getActivity());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setAdapter(adapter);
        recyclerView.addItemDecoration(new SpaceItemDecoration(8));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }

    @Override
    public void onFail() {

    }

}
